package ru.hh.school;

import java.util.*;

public class RoomManager {
    private Map<String, Room> rooms = new HashMap<String, Room>();
    private Map<Integer, Room> roomIds = new HashMap<Integer, Room>();

    public RoomManager(Set<Room> rooms) {
        for (Room room : rooms) {
            this.rooms.put(room.getName(), room);
            this.roomIds.put(room.getId(), room);
        }
    }

    public Room getRoom(String name) {
        return rooms.get(name);
    }

    public Room getRoom(int id) {
        return roomIds.get(id);
    }

    public List<String> getRoomNames() {
        ArrayList<String> result = new ArrayList<String>();
        for (Room room : rooms.values()) {
            result.add(room.getName());
        }
        return result;
    }
}
